package com.sky.festival.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sky.common.annotation.Log;
import com.sky.common.core.controller.BaseController;
import com.sky.common.core.domain.AjaxResult;
import com.sky.common.enums.BusinessType;
import com.sky.festival.domain.TbFilmFestival;
import com.sky.festival.service.ITbFilmFestivalService;
import com.sky.common.utils.poi.ExcelUtil;
import com.sky.common.core.page.TableDataInfo;

/**
 * 电影节管理Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/festival/festival")
public class TbFilmFestivalController extends BaseController
{
    @Autowired
    private ITbFilmFestivalService tbFilmFestivalService;

    /**
     * 查询电影节管理列表
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbFilmFestival tbFilmFestival)
    {
        startPage();
        List<TbFilmFestival> list = tbFilmFestivalService.selectTbFilmFestivalList(tbFilmFestival);
        return getDataTable(list);
    }

    /**
     * 导出电影节管理列表
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:export')")
    @Log(title = "电影节管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbFilmFestival tbFilmFestival)
    {
        List<TbFilmFestival> list = tbFilmFestivalService.selectTbFilmFestivalList(tbFilmFestival);
        ExcelUtil<TbFilmFestival> util = new ExcelUtil<TbFilmFestival>(TbFilmFestival.class);
        util.exportExcel(response, list, "电影节管理数据");
    }

    /**
     * 获取电影节管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbFilmFestivalService.selectTbFilmFestivalById(id));
    }

    /**
     * 新增电影节管理
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:add')")
    @Log(title = "电影节管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbFilmFestival tbFilmFestival)
    {
        return toAjax(tbFilmFestivalService.insertTbFilmFestival(tbFilmFestival));
    }

    /**
     * 修改电影节管理
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:edit')")
    @Log(title = "电影节管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbFilmFestival tbFilmFestival)
    {
        return toAjax(tbFilmFestivalService.updateTbFilmFestival(tbFilmFestival));
    }

    /**
     * 删除电影节管理
     */
    @PreAuthorize("@ss.hasPermi('festival:festival:remove')")
    @Log(title = "电影节管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbFilmFestivalService.deleteTbFilmFestivalByIds(ids));
    }
}
